package com.kuaidi.zhangke.kuaidi;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class FourActivity extends AppCompatActivity {


    @BindView(R.id.four_btn_swp)
    Button fourBtnSwp;
    @BindView(R.id.four_txt_code)
    EditText fourTxtCode;
    @BindView(R.id.four_btn_post)
    Button fourBtnPost;
    @BindView(R.id.four_btn_cancle)
    Button fourBtnCancle;
    String code=null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_four);
        ButterKnife.bind(this);
        code = getIntent().getStringExtra("code");
        if(code!=null&&!code.isEmpty()){

            fourTxtCode.setText(code);
        }



    }


    @OnClick({R.id.four_btn_swp, R.id.four_btn_post, R.id.four_btn_cancle})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.four_btn_swp:
                Intent intent =new Intent(FourActivity.this, SweepYardActivity.class);
                startActivity(intent);
                finish();
                break;
            case R.id.four_btn_post:

                String  code =fourTxtCode.getText().toString();

                if(code.isEmpty()){
                    Toast.makeText(FourActivity.this,"请输入快递单号",Toast.LENGTH_SHORT).show();

                }else  if(code.length()<2){
                    Toast.makeText(FourActivity.this,"单号有误",Toast.LENGTH_SHORT).show();
                }else {

                    intent =new Intent(FourActivity.this, FiveActivity.class);
                    intent.putExtra("code",code);
                    startActivity(intent);
                    finish();

                }



                break;
            case R.id.four_btn_cancle:
                break;
        }
    }
}
